<?php if(get_option('ini_bulletin')){?>
<div id="message">
<div id="message-body">
<div id="close">×</div>
<?php if(get_option('ini_admin')){
echo '<div id="login">';
global $user_ID, $user_identity, $user_email, $user_login;
get_currentuserinfo();
if (!$user_ID) {echo '<span class="author"><a href="'.get_bloginfo('url').'/wp-login.php?action=register">注册</a> | <a href="'.wp_login_url( home_url(add_query_arg(array(),$wp->request)) ).'">登陆</a></span>';}
else { echo '<span class="img">';global $userdata; get_currentuserinfo(); echo get_avatar($userdata->ID, 18); echo '</span> <span class="author">您好 '.$user_identity.' | <a href="'.get_bloginfo('url').'/wp-admin/">管理</a> | <a href="'.get_bloginfo('url').'/wp-login.php?action=logout&amp;amp;redirect_to='.urlencode($_SERVER['REQUEST_URI']).'">退出</a></span>';} echo '</div>';}?>
<div id="bulletin">
<ul>
<?php $loop = new WP_Query( array( 'post_type' => 'bulletin', 'posts_per_page' => '3' ) );
while ($loop->have_posts()): $loop->the_post(); ?>
<li><a href="<?php the_permalink(); ?>"><?php utf8_str(the_title(),0,30)?></a></li>
<?php endwhile;?>
</ul>
</div>
</div>
</div>
<?php } ?>
<script type="text/javascript">
(function (win){
var callboarTimer;
var bulletin = $('#bulletin');
var bulletinUl = bulletin.find('ul');
var bulletinLi = bulletin.find('li');
var liLen = bulletin.find('li').length;
var initHeight = bulletinLi.first().outerHeight(true);
win.autoAnimation = function (){
if (liLen <= 1) return;
var self = arguments.callee;
var bulletinLiFirst = bulletin.find('li').first();
bulletinLiFirst.animate({
marginTop:-initHeight
}, 500, function (){
clearTimeout(callboarTimer);
bulletinLiFirst.appendTo(bulletinUl).css({marginTop:0});
callboarTimer = setTimeout(self, 5000);
});
}
bulletin.mouseenter(
function (){
clearTimeout(callboarTimer);
}).mouseleave(function (){
callboarTimer = setTimeout(win.autoAnimation, 5000);
});
}(window));
setTimeout(window.autoAnimation, 5000);
$('#close').click(function(){$('#message').slideUp()});
</script>